<?php
require_once('../../Config/config.php');
require_once("qqConnectAPI.php");
$qc = new QC();
$back = $qc->qq_callback();
$openid = $qc->get_openid();

if($openid){
	if(@!$_COOKIE['uid']){
		$user_account = 'qq_'.$openid;
		require '../MyPdo.class.php';
		$pdo = new MyPdo();
		$sql = 'select user_id from tp_user where user_account = ?';
		$res = $pdo->dql($sql,array($user_account),1);
		if($res){
			//setCookie('uid',$res['user_id'],time()+600,'/');
			setCookie('uid',$res['user_id'],0,'/');
		}else{
			$sql = 'insert into tp_user(user_account,user_ctime) values(?,?)';
			$res = $pdo->dml($sql,array($user_account,time()));
			if($res > 0){
				setCookie('uid',$res,0,'/');
			}
		}
		header('location:../../../service_me.html');exit;
	}else{
		header('location:../../../service_me.html');exit;
	}
}else{
	header('location:../../../service_index.html');exit;
}